Victorious1 schrieb:
When the editcommand is execured for my datagrid the dropdown list appears
for the bound item status. However, the item selected by default does not
match the unedited data. How do I make the dropdownlist selected item match
the correspond to the original data. HTML for dropdownlist below
<EditItemTemplate>
<asp:DropDownList ID="DropDownListStatus" runat="server" DataValueField
= '<%# DataBinder.Eval(Container, "DataItem.screen_status") %>'
DataTextField
= '<%# DataBinder.Eval(Container, "DataItem.screen_status") %>'
Width="172px">
<asp:ListItem Value="FOLLOW-UP">FOLLOW-UP</asp:ListItem>
<asp:ListItem Value="PENDING">PENDING</asp:ListItem>
<asp:ListItem Value="DISCHARGE">DISCHARGE</asp:ListItem>
<asp:ListItem Value="IN PROGRESS">NOT APPROPRIATE</asp:ListItem>
<asp:ListItem Value="NOT APPROPRIATE">SCREENING</asp:ListItem>
<asp:ListItem Value="SCREENING">SCREENING</asp:ListItem>
<asp:ListItem Value="NOT INTERESTED">NOT INTERESTED</asp:ListItem>
<asp:ListItem Value="LOST-TO-FOLLOWUP">LOST-TO-FOLLOWUP</asp:ListItem>
</asp:DropDownList>
Hi,
I think the properties DataValueField and DataTextField are used only
when the elements for the drop down list are retrieved dynamically (from
a lookup table or something like that). But it looks like you have
static values in your drop down list and only want to select the one
that is in the database. For this, you need to bind the property
SelectedValue, in your example:
<asp:DropDownList ID="DropDownListStatus" runat="server" SelectedValue
= '<%# DataBinder.Eval(Container, "DataItem.screen_status") %>'
DataTextField
<asp:ListItem Value="FOLLOW-UP">FOLLOW-UP</asp:ListItem>
<asp:ListItem Value="PENDING">PENDING</asp:ListItem>
<asp:ListItem Value="DISCHARGE">DISCHARGE</asp:ListItem>
<asp:ListItem Value="IN PROGRESS">NOT APPROPRIATE</asp:ListItem>
<asp:ListItem Value="NOT APPROPRIATE">SCREENING</asp:ListItem>
<asp:ListItem Value="SCREENING">SCREENING</asp:ListItem>
<asp:ListItem Value="NOT INTERESTED">NOT INTERESTED</asp:ListItem>
<asp:ListItem Value="LOST-TO-FOLLOWUP">LOST-TO-FOLLOWUP</asp:ListItem>
</asp:DropDownList>
Also, please note that you have a discrepancy between your text and your
values (In progress - Not appropriate; Not appropriate - Screening)
Hope this helps,
Cheers,
Roland